$(function () {




    /*汇总表*/
    $('#hzb').bootstrapTable({
        url:'${pageContext.request.contextPath}/../../Qbb/Qchtongji',
        columns:[
            {
                field:'commtype.name',
                title:'商品类别'
            },{
                field:'number',
                title:'商品编号'
            },{
                field:'name',
                title:'商品名称'
            },{
                field:'num',
                title:'出货数量'
            },{
                field:'xx',
                title:'总金额',
                formatter: function (value, row, index) {
                    var jia = row.money * row.num;

                    return jia;
                }
            }],

        //method:'post',
        contentType:"application/x-www-form-urlencoded",

        queryParamsType:'',
        // detailView:true,

        queryParams: sss,

        height:500,
        pageList:[5,10,15],
        pageNumber:1,
        pageSize:5,
        pagination:true,
        sidePagination:'server',

    })


   /* Qchtongji*/
   /* 明细表*/
    $('#huopinchuhuomingxibiao').bootstrapTable({
        url:'${pageContext.request.contextPath}/../../Qbb/Qchtongji',
        columns:[
            {
                field:'order',
                title:'单号'
            },{
                field:'date',
                title:'订单时间'
            },{
                field:'commtype.name',
                title:'商品类别'
            },{
                field:'number',
                title:'商品编号'
            },{
                field:'name',
                title:'商品名称'
            },{
                field:'customer.name',
                title:'客户名称'
            },{
                field:'comptype.name',
                title:'单位'
            },{
                field:'money',
                title:'出货单价'
            },{
                field:'num',
                title:'数量'

            },{
                field:'xx',
                title:'总金额',
                formatter: function (value, row, index) {
                    var jia = row.money * row.num;

                    return jia;
                }
            },{
                field:'warehouse.name',
                title:'仓库名称'
            },{
                field:'specid',
                title:'规格'
            },{
                field:'colortype.name',
                title:'颜色'
            }],



        //method:'post',
        contentType:"application/x-www-form-urlencoded",

        queryParamsType:'',
        // detailView:true,

        queryParams: ss,

        height:500,
        pageList:[5,10,15],
        pageNumber:1,
        pageSize:5,
        pagination:true,
        sidePagination:'server',

    })


    /*出货货品出货表*/
    $('#Qhpchtongjibiao').bootstrapTable({
        url:'${pageContext.request.contextPath}/../../Qbb/Qhpchtongjibiao',
        columns:[
            {
                field:'name',
                title:'商品类别'
            },{
                field:'num',
                title:'出货数量'
            },{
                field:'money',
                title:'出货金额'
            }],

        queryParams: f,


    })


    /*按供货商统计*/
    $('#jhfl').bootstrapTable({
        url:'${pageContext.request.contextPath}/../../Qbb/Qangonghuoshang',
        columns:[
            {
                field:'id',
                title:'供货商编号'
            },{
                field:'name',
                title:'供货商名称'
            },
            {
                field:'num',
                title:'出货数量'
            },{
                field:'money',
                title:'出货金额'
            },{
                field:'xx',
                title:'总金额',
                formatter: function (value, row, index) {
                    var jia = row.money * row.num;

                    return jia;
                }
            }],
        detailView:true,
        queryParams: ff,
        //当点击详细图标展开详细页面的时候触发。
        onExpandRow: function (index, row, $detail) {
            var table = $detail.html("<table></table>").find("table") ;
            table.bootstrapTable({
                url: '${pageContext.request.contextPath}/../../Qbb/Qangonghuoshangxx?typeid='+row.id+'',
                columns:[
                    {
                        field:'order',
                        title:'单号'
                    },{
                        field:'date',
                        title:'订单时间'
                    },{
                        field:'commtype.name',
                        title:'商品类别'
                    },{
                        field:'number',
                        title:'商品编号'
                    },{
                        field:'name',
                        title:'商品名称'
                    },{
                        field:'money',
                        title:'出货单价'
                    },{
                        field:'num',
                        title:'数量'

                    },{
                        field:'xx',
                        title:'总金额',
                        formatter: function (value, row, index) {
                            var jia = row.money * row.num;

                            return jia;
                        }
                    },{
                        field:'warehouse.name',
                        title:'仓库名称'
                    },{
                        field:'specid',
                        title:'规格'
                    },{
                        field:'colortype.name',
                        title:'颜色'
                    }],


            }) ;
        }







    })


    /*按客户统计*/
    $('#kkkhh').bootstrapTable({
        url:'${pageContext.request.contextPath}/../../Qbb/Qankehutongji',
        columns:[
            {
                field:'id',
                title:'客户编号'
            },{
                field:'name',
                title:'客户名称'
            },
            {
                field:'num',
                title:'出货数量'
            },{
                field:'money',
                title:'出货金额'
            },{
                field:'xx',
                title:'总金额',
                formatter: function (value, row, index) {
                    var jia = row.money * row.num;

                    return jia;
                }
            }],








        detailView:true,
        queryParams: ffc,


        //当点击详细图标展开详细页面的时候触发。
        onExpandRow: function (index, row, $detail) {
            var table = $detail.html("<table></table>").find("table") ;
            table.bootstrapTable({
                url: '${pageContext.request.contextPath}/../../Qbb/Qangonghuoshangxx?typeid='+row.id+'',
                columns:[
                    {
                        field:'order',
                        title:'单号'
                    },{
                        field:'date',
                        title:'订单时间'
                    },{
                        field:'commtype.name',
                        title:'商品类别'
                    },{
                        field:'number',
                        title:'商品编号'
                    },{
                        field:'name',
                        title:'商品名称'
                    },{
                        field:'customer.name',
                        title:'客户名称'
                    },{
                        field:'comptype.name',
                        title:'单位'
                    },{
                        field:'money',
                        title:'出货单价'
                    },{
                        field:'num',
                        title:'数量'

                    },{
                        field:'xx',
                        title:'总金额',
                        formatter: function (value, row, index) {
                            var jia = row.money * row.num;

                            return jia;
                        }
                    },{
                        field:'warehouse.name',
                        title:'仓库名称'
                    },{
                        field:'specid',
                        title:'规格'
                    },{
                        field:'colortype.name',
                        title:'颜色'
                    }],


            }) ;
        }
    })

   /* 出货排行*/
  $('#paihangg').bootstrapTable({
        url:'${pageContext.request.contextPath}/../../Qbb/Qpaihang',
        columns:[
            {
                field:'name',
                title:'商品类别'
            },{
                field:'nn',
                title:'商品编号'
            }],
    })






    /*供货商所有单据*/
    $('#firstDate').datetimepicker({
        //viewMode: 'day',
        format: 'YYYY-MM-DD'
    });
    $('#secondDate').datetimepicker({
        format: 'YYYY-MM-DD',
        useCurrent: false //Important! See issue #1075
    });
    $("#firstDate").on("dp.change", function (e) {
        $('#secondDate').data("DateTimePicker").minDate(e.date);
    });
    $("#secondDate").on("dp.change", function (e) {
        $('#firstDate').data("DateTimePicker").maxDate(e.date);
    });


    $('#firstDate1').datetimepicker({
        //viewMode: 'day',
        format: 'YYYY-MM-DD'
    });
    $('#secondDate1').datetimepicker({
        format: 'YYYY-MM-DD',
        useCurrent: false //Important! See issue #1075
    });
    $("#firstDate1").on("dp.change", function (e) {
        $('#secondDate1').data("DateTimePicker").minDate(e.date);
    });
    $("#secondDate1").on("dp.change", function (e) {
        $('#firstDate1').data("DateTimePicker").maxDate(e.date);
    });


    $('#firstDate4').datetimepicker({
        //viewMode: 'day',
        format: 'YYYY-MM-DD'
    });
    $('#secondDate4').datetimepicker({
        format: 'YYYY-MM-DD',
        useCurrent: false //Important! See issue #1075
    });
    $("#firstDate4").on("dp.change", function (e) {
        $('#secondDate4').data("DateTimePicker").minDate(e.date);
    });
    $("#secondDate4").on("dp.change", function (e) {
        $('#firstDate4').data("DateTimePicker").maxDate(e.date);
    });



    $('#firstDate5').datetimepicker({
        //viewMode: 'day',
        format: 'YYYY-MM-DD'
    });
    $('#secondDate5').datetimepicker({
        format: 'YYYY-MM-DD',
        useCurrent: false //Important! See issue #1075
    });
    $("#firstDate5").on("dp.change", function (e) {
        $('#secondDate4').data("DateTimePicker").minDate(e.date);
    });
    $("#secondDate5").on("dp.change", function (e) {
        $('#firstDate4').data("DateTimePicker").maxDate(e.date);
    });



    $('#firstDate7').datetimepicker({
        //viewMode: 'day',
        format: 'YYYY-MM-DD'
    });
    $('#secondDate7').datetimepicker({
        format: 'YYYY-MM-DD',
        useCurrent: false //Important! See issue #1075
    });
    $("#firstDate7").on("dp.change", function (e) {
        $('#secondDate4').data("DateTimePicker").minDate(e.date);
    });
    $("#secondDate7").on("dp.change", function (e) {
        $('#firstDate4').data("DateTimePicker").maxDate(e.date);
    });







})


/*明细表*/
function op() {

    var opt = $("#huopinchuhuomingxibiao").bootstrapTable('getOptions');

    var firstDate = $("#firstDate").val() ;

    var secondDate = $("#secondDate").val();

    var typeid = $('#soso').combogrid('getValue');

    var name=$('#nn').val();

    $.post('${pageContext.request.contextPath}/../../Qbb/Qchtongji',{'name':name,'typeid':typeid,'pageNumber':1,'pageSize':opt.pageSize,'firstDate':firstDate,'secondDate':secondDate},function(data){
        //重新给table绑定数据
        $("#huopinchuhuomingxibiao").bootstrapTable("load",data) ;
    }) ;


}
function ss(params) {
    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
        'pageSize': params.pageSize,  //页面大小
        'pageNumber': params.pageNumber, //页码
        'firstDate':$("#firstDate").val(),
        'secondDate':$("#secondDate").val(),
        'typeid':$("#soso").combogrid('getValue'),
        'name':$("#nn").val()
    };
    return temp;
};



/*汇总表*/
function zzz() {

    var opt = $("#hzb").bootstrapTable('getOptions');

    var firstDate1 = $("#firstDate1").val() ;

    var secondDate1 = $("#secondDate1").val();

    var typeid1 = $('#soso1').combogrid('getValue');


    var name1=$('#nn1').val();


    $.post('${pageContext.request.contextPath}/../../Qbb/Qchtongji',{'name1':name1,'typeid1':typeid1,'pageNumber':1,'pageSize':opt.pageSize,'firstDate1':firstDate1,'secondDate':secondDate1},function(data){
        //重新给table绑定数据
        $("#hzb").bootstrapTable("load",data) ;
    }) ;


}
function sss(params) {
    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
        'pageSize': params.pageSize,  //页面大小
        'pageNumber': params.pageNumber, //页码
        'firstDate1':$("#firstDate1").val(),
        'secondDate1':$("#secondDate1").val(),
        'typeid1':$("#soso1").combogrid('getValue'),
        'name1':$("#nn1").val()
    };
    return temp;
};

/*货品出货分类的图*/
function zmby() {
    var firstDate1 = $("#firstDate4").val() ;

    var secondDate1 = $("#secondDate4").val();

    var typeid1 = $('#soso4').combogrid('getValue');


    var name4=$('#nn1').val();


    $.post('${pageContext.request.contextPath}/../../Qbb/Qhpchtongjibiao',{'name':name4,'typeid':typeid1,'firstDate':firstDate1,'secondDate':secondDate1},function(data){
        //重新给table绑定数据
        $("#Qhpchtongjibiao").bootstrapTable("load",data) ;
    }) ;
}
function f(params) {
    var temp={
        'firstDate1':$("#firstDate4").val(),
        'secondDate1':$("#secondDate4").val(),
        'typeid1':$("#soso4").combogrid('getValue'),
        'name1':$("#nn4").val()
    };
    return temp;
}

/*按供货商统计*/
function an() {
    var opt = $("#jhfl").bootstrapTable('getOptions');
    var name4=$('#tt').val();
    $.post('${pageContext.request.contextPath}/../../Qbb/Qangonghuoshang',{'name':name4},function(data){
        //重新给table绑定数据
        $("#jhfl").bootstrapTable("load",data) ;
    }) ;
}
function ff(params) {
    var temp={
        'firstDate':$("#firstDate5").val(),
        'secondDate':$("#secondDate5").val(),
        /*'typeid':$("#soso5").combogrid('getValue'),*/
        'name':$("#tt").val()
    };
    return temp;
}



/*按客户查询*/
function ankh() {
    var opt = $("#kkkhh").bootstrapTable('getOptions');
    var supplierid=$('#o').combogrid('getValue');
    $.post('${pageContext.request.contextPath}/../../Qbb/Qankehutongji',{'supplierid':supplierid,},function(data){
        //重新给table绑定数据
        $("#kkkhh").bootstrapTable("load",data) ;
    }) ;
}
function ffc(params) {
    var temp={
        'supplierid':$("#o").val()
    };
    return temp;
}

/*出货排行*/
function ooop() {

    var opt = $("#paihangg").bootstrapTable('getOptions');

    var firstDate = $("#firstDate7").val() ;

    var secondDate = $("#secondDate7").val();

    var typeid = $('#soso7').combogrid('getValue');





    $.post('${pageContext.request.contextPath}/../../Qbb/Qpaihang',{'typeid':typeid,'firstDate':firstDate,'secondDate':secondDate},function(data){
        //重新给table绑定数据
        $("#paihangg").bootstrapTable("load",data) ;
    }) ;
}
function paihh(params) {
    var temp={
        'firstDate':$("#firstDate7").val(),
        'secondDate':$("#secondDate7").val(),
        'typeid':$("#soso7").combogrid('getValue'),
        'name':$("#07").val()
    };
    return temp;
}







